#include "bullet.h"
#include "config.h"

bullet::bullet()
{
    m_bullet.load(":/picture/images/bullet2.png");
    m_bullet2.load(":/picture/images/bullet1.png");
    m_x=(GAME_WIDTH-m_bullet.width())*0.5;
    m_y=GAME_HEIGHT;
    m_free=true;
    m_speed=BULLET_SPEED;
    m_Rect.setWidth(m_bullet.width());
    m_Rect.setHeight(m_bullet.height());
    m_Rect.moveTo(m_x,m_y);
}

void bullet::updatePosition()
{
    //空闲状态不计算坐标
    if(m_free){return;}
     m_y -= m_speed;
     m_Rect.moveTo(m_x,m_y);
     if(m_y<=-m_Rect.height())
     {
         m_free=true;
     }
}
